package com.gooddare.view.component 
{
	import com.gooddare.controller.ApplicationFacade;
	import com.riatimes.mvc.view.BaseComponent;
	import flash.display.Loader;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	/**
	 * ...
	 * @author Eric
	 */
	public class DispicItemComponent extends BaseComponent
	{
		public var id:int;
		private var imgUrl:String;
		private var loader:Loader;
		public function DispicItemComponent(id:int,imgUrl:String) 
		{
			this.id = id;
			this.imgUrl = imgUrl;
		}
		override public function initUI():void {
			loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, __loaderEventHandle);
			loader.load(new URLRequest(imgUrl));
		}
		
		private function __loaderEventHandle(e:Event):void 
		{
			this.addChild(loader);
			this.x = -loader.width / 2;
			this.y = -loader.height / 2;
			this.addEventListener(MouseEvent.CLICK, __mouseEventClickHandle);
		}
		
		private function __mouseEventClickHandle(e:MouseEvent):void 
		{
			ApplicationFacade.getInstance().sendNotification(ApplicationFacade.EVENT_APP_PHOTO_DISPLAY_GET_INDEX, id);
		}
	}

}